var ec_map = echarts.init(document.getElementById('map'));

var mydata = [{'name': '上海', 'value': 318}, {'name': '云南', 'value': 162}]

var ec_center_option = {
    title: {
        text: '全国现有确诊',
        subtext: '',
        x: 'left'
    },

    tooltip: {
        trigger: 'item'
    },
    //左侧小导航图标
    visualMap: {
        show: true,
        x: 'left',
        y: 'bottom',
        textStyle: {
            fontSize: 8,
        },
        splitList: [{ start: 1,end: 9 },
            {start: 10, end: 99 }, 
			{ start: 100, end: 999 },
            {  start: 1000, end: 9999 },
            { start: 10000 }],
        color: ['#8A3310', '#C64918', '#E55B25', '#F2AD92', '#F9DCD1']
    },
    //配置属性
    series: [{
        name: '现有确诊人数',
        type: 'map',
        mapType: 'china',
        roam: true, //拖动和缩放
        itemStyle: {
            normal: {
                borderWidth: .5, //区域边框宽度
                borderColor: '#62d3ff', //区域边框颜色
                areaColor: "#b7ffe6", //区域颜色
            },
            emphasis: { //鼠标滑过地图高亮的相关设置
                borderWidth: .5,
                borderColor: '#fff',
                areaColor: "#fff",
            }
        },
        label: {
            normal: {
                show: true, //省份名称
                fontSize: 8,
            },
            emphasis: {
                show: true,
                fontSize: 8,
            }
        },
        data:[] //mydata //数据
    }]
};
ec_map.setOption(ec_center_option)

var option1 = {
	title: {
		text: '',
		subtext: '',
		x: 'left'
	},
	tooltip: {
		trigger: 'item'
		//触发类型
	},
	//左侧小导航图标
	visualMap: {
		show: true,
		x: 'left',
		y: 'bottom',
		textStyle: {
			fontSize: 8,
		},
		splitList: [{
				start: 1,
				end: 9
			},
			{
				start: 10,
				end: 99
			},
			{
				start: 100,
				end: 999
			},
			{
				start: 1000,
				end: 9999
			},
			{
				start: 10000
			}
		],
		color: ['#8A3310', '#C64918', '#E55B25', '#F2AD92', '#F9DCD1']
	},
	//配置属性
	series: [{
		name: '累计确诊人数',
		type: 'map',
		mapType: [],
		roam: true, //拖动和缩放
		itemStyle: {
			normal: {
				borderWidth: .5, //区域边框宽度
				borderColor: '#009fe8', //区域边框颜色
				areaColor: "#ffefd5", //区域颜色
			},
			emphasis: { //鼠标滑过地图高亮的相关设置
				borderWidth: .5,
				borderColor: '#4b0082',
				areaColor: "#fff",
			}
		},
		label: {
			normal: {
				show: true, //省份名称
				fontSize: 8,
			},
			emphasis: {
				show: true,
				fontSize: 8,
			}
		},
		data: []//mydata //数据
	}]
};

ec_map.on('click', function(params) {
	city = params.name;
	$.ajax({
		url: "/province",
		success: function(data) {
			ec_map.clear();
			option1.series[0].mapType = city
			option1.series[0].data = data.mydata
			ec_map.setOption(option1)
		},
		error: function(xhr, type, errorThrown) {

		}
	})
});

function ret(){
	ec_map.clear();
	ec_map.setOption(ec_center_option)
}
